% Macros for verbatim TeX (from MANMAC.TEX): % After \inputing this file you can use the following macros: % 1. || % 2. \begintt % % \endtt % 3. \begindisplay % % |text in \tt|& |text in \tt|& text in current font\cr % \enddisplay % 4. \listing{foo} % foo.tex will be \input and set verbatim in \tt; \parskip must be non-zero % if you want to see any empty lines \catcode`@=11 % borrow some PLAIN macros which use @ as a letter \newskip\ttglue \ttglue=0.5em plus.25em minus.15em \chardef\other=12 \def\ttverbatim{\begingroup \catcode`\\=\other \catcode`\{=\other \catcode`\}=\other \catcode`\$=\other \catcode`\&=\other \catcode`\#=\other \catcode`\%=\other \catcode`\~=\other \catcode`\_=\other \catcode`\^=\other \obeyspaces \obeylines \tt} {\obeyspaces\gdef {\ }} % active space = \ , not \space \outer\def\begintt{$$\let\par=\endgraf \ttverbatim \parskip=\z@ \catcode`\|=0 \rightskip-5pc \ttfinish} {\catcode`\|=0 |catcode`|\=\other % | is temporary escape character |obeylines % end of line is active |gdef|ttfinish#1^^M#2\endtt{#1|dimen0=|hsize|advance|dimen0 by -|hangindent% |hsize=|dimen0|vbox{#2}|endgroup$$}} % \begintt ... \endtt will now work in a paragraph with \hangindent, such % as an \item \catcode`\|=\active {\obeylines \gdef|{\ttverbatim \spaceskip\ttglue \let^^M=\ \let|=\endgroup}} \catcode`@=12 % return @ its normal category of "other" % Macros for non-centered displays: % Note that we turn \ttglue off so |stuff| spaces will all be equal. \outer\def\begindisplay{\obeylines\startdisplay} {\obeylines\gdef\startdisplay#1 {\catcode`\^^M=5$$\ttglue=0em#1\halign to\hsize% \bgroup\indent##\hfil\tabskip 0pt plus 1000pt&&\qquad##\hfil\cr}} \outer\def\enddisplay{\crcr\egroup$$} % MACROS FOR VERBATIM LISTINGS (ADAPTED FROM TEXBOOK APPENDIX D, P380) \def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials} \def\setupverbatim{\tt \def\par{\leavevmode\endgraf} \catcode`\`=\active % include empty lines \obeylines \uncatcodespecials \obeyspaces} {\catcode`\`=\active \gdef`{\relax\lq}} \def\listing#1{\par\begingroup\parindent0pt \parskip0pt \vskip\baselineskip \setupverbatim \catcode`\|=\other % allow | in listing file \input#1 \vskip\baselineskip\endgroup}